****************************************************************************************************
* Purpose: Create figures for diabetes and mortality paper
* Written by: Hunter Green
* Last updated: 2024-12-28
* Stata version: 18.0
****************************************************************************************************

* Toggle for whether David is working on this
global David = "F"


****************************************************************************************************
* Options, global macros, log, install packages
****************************************************************************************************
* Options
version 18.0
clear all
set more off
set varabbrev off
pause on
graph set window fontface "Arial"

* Use the macro $S_DATE to save files with current date
global date : disp %tdCCYY.NN.DD date("$S_DATE","DMY")

* Global folder macros
if "${David}" == "T" {	//David add your folder paths here
	* paper
	global paper_code "/Users/dcflood/Library/CloudStorage/Dropbox-UniversityofMichigan/David Flood/HPACC/Aging projects/HRS diabetes mortality/Code"
	global paper_tables "/Users/dcflood/Library/CloudStorage/Dropbox-UniversityofMichigan/David Flood/HPACC/Aging projects/HRS diabetes mortality/Tables"
	global paper_figures "/Users/dcflood/Library/CloudStorage/Dropbox-UniversityofMichigan/David Flood/HPACC/Aging projects/HRS diabetes mortality/Figures"
}
else {
	* paper
	global paper_code "/Users/dcflood/Library/CloudStorage/Dropbox-UniversityofMichigan/David Flood/HPACC/Aging projects/HRS diabetes mortality/Code"
	global paper_tables "/Users/dcflood/Library/CloudStorage/Dropbox-UniversityofMichigan/David Flood/HPACC/Aging projects/HRS diabetes mortality/Tables"
	global paper_figures "/Users/dcflood/Library/CloudStorage/Dropbox-UniversityofMichigan/David Flood/HPACC/Aging projects/HRS diabetes mortality/Figures"
}

* Open log
capture log close
log using "${paper_code}/04_diab-mort-figures-stata.log", replace

* Install packages
* Forest plot
*ssc install metan, replace


****************************************************************************************************
****************************************************************************************************
* Figure 3, Panel A
****************************************************************************************************
****************************************************************************************************
* Load data
import excel "${paper_tables}/Figure3a_data.xlsx", sheet("Sheet1") firstrow clear

* Indicator variable needed for forestplot to work
gen _USE = 1
replace _USE = 0 if mi(mrr_coef)

* Indicator variable needed to make symbols different
gen plotid = 1 if label == "Women" | label == "Men"
replace plotid = 2 if label == "Overall"

* Label variables
label variable label "{bf:Country}"
label variable mrr `"`"{bf:Mortality rate}"' `"{bf:ratio}"'"'
label variable mrd `"`"{bf:Mortality rate}"' `"{bf:difference}"'"'

replace label = "{bf:China (CHARLS)}" if label == "China (CHARLS)"
replace label = "{bf:England (ELSA)}" if label == "England (ELSA)"
replace label = "{bf:Mexico (MHAS)}" if label == "Mexico (MHAS)"
replace label = "{bf:South Africa (HAALSI)}" if label == "South Africa (HAALSI)"
replace label = "{bf:United States (HRS)}" if label == "United States (HRS)"

* Log of variables
destring mrr_coef mrr_lower mrr_upper mrd_coef mrd_lower mrd_upper, replace
replace mrr_coef = log(mrr_coef)
replace mrr_lower = log(mrr_lower)
replace mrr_upper = log(mrr_upper)

* Plot
forestplot mrr_coef mrr_lower mrr_upper, eform ///
           /// graph attributes
           labels(label) plotid(plotid) rcols(mrr) leftjustify nostats nobox astext(70) ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lwidth(0)) ///
           point1opts(msymbol(square) msize(0.25rs) mcolor(black)) ci1opts(lcolor(black) lwidth(0.2rs)) ///
           point2opts(msymbol(diamond) msize(0.25rs) mcolor(cranberry)) ci2opts(lcolor(cranberry) lwidth(0.2rs)) ///
           /// x-axis
           range(0.5 4) null(1) xlabel(0.5 "0.5" 1 2 4, labsize(2.5) nogrid) ///
           xtitle("Mortality rate ratio", size(2.5) margin(l=7 r=0 b=0 t=1)) ///          
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           aspect(1) savedims(A) ///
           /// name
           name(fig_mrr)

gr_edit .plotregion1.plot8.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1.plot9.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

forestplot mrd_coef mrd_lower mrd_upper, ///
           /// graph attributes
           plotid(plotid) rcols(mrd) leftjustify nostats nobox ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lwidth(0)) ///
           point1opts(msymbol(square) msize(0.25rs) mcolor(black)) ci1opts(lcolor(black) lwidth(0.2rs)) ///
           point2opts(msymbol(diamond) msize(0.25rs) mcolor(cranberry)) ci2opts(lcolor(cranberry) lwidth(0.2rs)) ///
           /// x-axis
           range(-20 60) null(0) xlabel(-20 0 20 40 60, labsize(2.5) nogrid) ///
           xtitle("Mortality rate difference", size(2.5) margin(l=0 r=28 b=0 t=1)) ///         
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           usedims(A) ///
           /// name
           name(fig_mrd)

gr_edit .plotregion1.plot8.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

graph combine fig_mrr fig_mrd, graphregion(color(white) lcolor(white) margin(zero)) ysize(4) xsize(5.5)

* Export figure
graph export "${paper_figures}/Figure3a_forest_${date}.png", as(png) replace
clear all


****************************************************************************************************
****************************************************************************************************
* Figure 3, Panel B
****************************************************************************************************
****************************************************************************************************
* Load data
import excel "${paper_tables}/Figure3b_data.xlsx", sheet("Sheet1") firstrow clear

* Indicator variable needed for forestplot to work
gen _USE = 1
replace _USE = 0 if mi(mrr_coef)

* Label variables
label variable label "{bf:Country}"
label variable mrr `"`"{bf:Mortality rate}"' `"{bf:ratio}"'"'
label variable mrd `"`"{bf:Mortality rate}"' `"{bf:difference}"'"'

replace label = "{bf:China (CHARLS)}" if label == "China (CHARLS)"
replace label = "{bf:England (ELSA)}" if label == "England (ELSA)"
replace label = "{bf:Mexico (MHAS)}" if label == "Mexico (MHAS)"
replace label = "{bf:South Africa (HAALSI)}" if label == "South Africa (HAALSI)"
replace label = "{bf:United States (HRS)}" if label == "United States (HRS)"

* Log of variables
destring mrr_coef mrr_lower mrr_upper mrd_coef mrd_lower mrd_upper, replace
replace mrr_coef = log(mrr_coef)
replace mrr_lower = log(mrr_lower)
replace mrr_upper = log(mrr_upper)

* Plot
forestplot mrr_coef mrr_lower mrr_upper, eform ///
           /// graph attributes
           labels(label) rcols(mrr) leftjustify nostats nobox astext(70) ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lwidth(0)) ///
           point1opts(msymbol(square) msize(0.25rs) mcolor(black)) ci1opts(lcolor(black) lwidth(0.2rs)) ///
           /// x-axis
           range(0.5 4) null(1) xlabel(0.5 "0.5" 1 2 4, labsize(2.5) nogrid) ///
           xtitle("Mortality rate ratio", size(2.5) margin(l=15 r=0 b=0 t=1)) ///
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           aspect(1) savedims(A) ///
           /// name
           name(fig_mrr)

gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1.plot6.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

forestplot mrd_coef mrd_lower mrd_upper, ///
           /// graph attributes
           rcols(mrd) leftjustify nostats nobox ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lwidth(0)) ///
           point1opts(msymbol(square) msize(0.25rs) mcolor(black)) ci1opts(lcolor(black) lwidth(0.2rs)) ///
           /// x-axis
           range(-20 60) null(0) xlabel(-20 0 20 40 60, labsize(2.5) nogrid) ///
           xtitle("Mortality rate difference", size(2.5) margin(l=0 r=28 b=0 t=1)) ///
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           usedims(A) ///
           /// name
           name(fig_mrd)

gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

graph combine fig_mrr fig_mrd, graphregion(color(white) lcolor(white) margin(zero)) ysize(4) xsize(5.5)

* Export figure
graph export "${paper_figures}/Figure3b_forest_${date}.png", as(png) replace
clear all


****************************************************************************************************
****************************************************************************************************
* Appendix 7 data - Mortality rate ratios by age groups
****************************************************************************************************
****************************************************************************************************
* Load data
import excel "${paper_tables}/Appendix7_data.xlsx", sheet("Sheet1") firstrow clear

* Indicator variable needed for forestplot to work
gen _USE = 1
replace _USE = 0 if mi(mrr_coef)

* Label variables
label variable label "{bf:Country}"
label variable mrr `"`"{bf:Mortality rate}"' `"{bf:ratio}"'"'

replace label = "{bf:China (CHARLS)}" if label == "China (CHARLS)"
replace label = "{bf:England (ELSA)}" if label == "England (ELSA)"
replace label = "{bf:Mexico (MHAS)}" if label == "Mexico (MHAS)"
replace label = "{bf:South Africa (HAALSI)}" if label == "South Africa (HAALSI)"
replace label = "{bf:United States (HRS)}" if label == "United States (HRS)"

* Log of variables
destring mrr_coef mrr_lower mrr_upper, replace
replace mrr_coef = log(mrr_coef)
replace mrr_lower = log(mrr_lower)
replace mrr_upper = log(mrr_upper)

* Plot
forestplot mrr_coef mrr_lower mrr_upper, eform ///
           /// graph attributes
           labels(label) rcols(mrr) leftjustify nostats nobox astext(70) ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lwidth(0)) ///
           point1opts(msymbol(square) msize(0.25rs) mcolor(black)) ci1opts(lcolor(black) lwidth(0.2rs)) ///
           /// x-axis
           range(0.5 6) null(1) xlabel(0.5 "0.5" 1 2 4 6, labsize(2.5) nogrid) ///
           xtitle("Mortality rate ratio", size(2.5) margin(l=4 r=0 b=0 t=1)) ///
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           aspect(1) savedims(A) ///
           /// name
           name(fig_mrr)

gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1.plot6.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

* Export figure
graph export "${paper_figures}/Appendix7_forest_${date}.png", as(png) replace
clear all


****************************************************************************************************
****************************************************************************************************
* Appendix 8 data - comparisons of diagnosed vs. undiagnosed
****************************************************************************************************
****************************************************************************************************
* Load data
import excel "${paper_tables}/Appendix8_data.xlsx", sheet("Sheet1") firstrow clear

* Indicator variable needed for forestplot to work
gen _USE = 1
replace _USE = 0 if mi(mrr_coef)

* Label variables
label variable label "{bf:Country}"
label variable mrr `"`"{bf:Mortality rate}"' `"{bf:ratio}"'"'
label variable mrd `"`"{bf:Mortality rate}"' `"{bf:difference}"'"'

* Log of variables
destring mrr_coef mrr_lower mrr_upper mrd_coef mrd_lower mrd_upper, replace
replace mrr_coef = log(mrr_coef)
replace mrr_lower = log(mrr_lower)
replace mrr_upper = log(mrr_upper)

* Plot
forestplot mrr_coef mrr_lower mrr_upper, eform ///
           /// graph attributes
           labels(label) rcols(mrr) leftjustify nostats nobox astext(70) ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
           /// x-axis
           range(0.5 4) null(1) xlabel(0.5 "0.5" 1 2 4, labsize(2.5) nogrid) ///
           xtitle("Mortality rate ratio", size(2.5) margin(l=6 r=0 b=0 t=1)) ///
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           aspect(0.5) savedims(A) ///
           /// name
           name(fig_mrr)

gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1.plot6.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

forestplot mrd_coef mrd_lower mrd_upper, ///
           /// graph attributes
           rcols(mrd) leftjustify nostats nobox ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
           /// x-axis
           range(-20 60) null(0) xlabel(-20 0 20 40 60, labsize(2.5) nogrid) ///
           xtitle("Mortality rate difference", size(2.5) margin(l=0 r=30 b=0 t=1)) ///         
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           usedims(A) ///
           /// name
           name(fig_mrd)

gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

graph combine fig_mrr fig_mrd, graphregion(color(white) lcolor(white) margin(zero)) ysize(4) xsize(5.5)

* Export figure
graph export "${paper_figures}/Appendix8_forest_${date}.png", as(png) replace
clear all


// ****************************************************************************************************
// ****************************************************************************************************
// * Appendix 9 data - sensitivity analysis using Cox proportional hazards models instead of Poisson
// *                   with an offset for log-transformed person-years and robust standard errors
// ****************************************************************************************************
// ****************************************************************************************************
// * Load data
// import excel "${paper_tables}/Appendix9_data.xlsx", sheet("Sheet1") firstrow clear
//
// * Indicator variable needed for forestplot to work
// gen _USE = 1
// replace _USE = 0 if mi(mrr_coef) & mi(hr_coef)
//
// * Label variables
// label variable label "{bf:Country}"
// label variable mrr `"`"{bf:Mortality rate}"' `"{bf:ratio}"'"'
// label variable hr `"`"{bf:Hazard}"' `"{bf:ratio}"'"'
//
// * Log of variables
// destring mrr_coef mrr_lower mrr_upper hr_coef hr_lower hr_upper, replace
// replace mrr_coef = log(mrr_coef)
// replace mrr_lower = log(mrr_lower)
// replace mrr_upper = log(mrr_upper)
// replace hr_coef = log(hr_coef)
// replace hr_lower = log(hr_lower)
// replace hr_upper = log(hr_upper)
//
// * Plot
// forestplot mrr_coef mrr_lower mrr_upper, eform ///
//            /// graph attributes
//            labels(label) rcols(mrr) leftjustify nostats nobox astext(70) ///
//            /// markers           
//            nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
//            /// x-axis
//            range(0.5 4) null(1) xlabel(0.5 "0.5" 1 2 3, labsize(2.5) nogrid) ///
//            xtitle("Mortality rate ratio", size(2.5) margin(l=3 r=0 b=0 t=1)) ///
//            /// plot/graph region
//            plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
//            graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
//            /// size
//            aspect(0.5) savedims(A) ///
//            /// name
//            name(fig_mrr)
//           
// gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
// gr_edit .plotregion1.plot6.style.editstyle label(textstyle(size(3))) editcopy
// gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
// gr_edit .yaxis1.draw_view.setstyle, style(off)
//
// forestplot hr_coef hr_lower hr_upper, eform ///
//            /// graph attributes
//            rcols(hr) leftjustify nostats nobox ///
//            /// markers           
//            nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
//            /// x-axis
//            range(0.5 4) null(1) xlabel(0.5 "0.5" 1 2 3, labsize(2.5) nogrid) ///
//            xtitle("Hazard ratio", size(2.5) margin(l=0 r=35 b=0 t=1)) ///         
//            /// plot/graph region
//            plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
//            graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
//            /// size
//            usedims(A) ///
//            /// name
//            name(fig_hr)
//           
// gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
// gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
// gr_edit .yaxis1.draw_view.setstyle, style(off)
//
// graph combine fig_mrr fig_hr, graphregion(color(white) lcolor(white) margin(zero)) ysize(4) xsize(5.5)
//
// * Export figure
// graph export "${paper_figures}/Appendix9_forest_${date}.png", as(png) replace
// clear all


****************************************************************************************************
****************************************************************************************************
* Appendix 10 data - sensitivity analysis using self-report of diabetes medication instead of
*                    self-report of diabetes diagnosis
****************************************************************************************************
****************************************************************************************************
* Load data
import excel "${paper_tables}/Appendix10_data.xlsx", sheet("Sheet1") firstrow clear

* Indicator variable needed for forestplot to work
gen _USE = 1
replace _USE = 0 if mi(mrr_coef)

* Label variables
label variable label "{bf:Country}"
label variable mrr `"`"{bf:Mortality rate}"' `"{bf:ratio}"'"'
label variable mrd `"`"{bf:Mortality rate}"' `"{bf:difference}"'"'

* Log of variables
destring mrr_coef mrr_lower mrr_upper mrd_coef mrd_lower mrd_upper, replace
replace mrr_coef = log(mrr_coef)
replace mrr_lower = log(mrr_lower)
replace mrr_upper = log(mrr_upper)

* Plot
forestplot mrr_coef mrr_lower mrr_upper, eform ///
           /// graph attributes
           labels(label) rcols(mrr) leftjustify nostats nobox astext(70) ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
           /// x-axis
           range(0.5 4) null(1) xlabel(0.5 "0.5" 1 2 3, labsize(2.5) nogrid) ///
           xtitle("Mortality rate ratio", size(2.5) margin(l=2 r=0 b=0 t=1)) ///
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           aspect(0.5) savedims(A) ///
           /// name
           name(fig_mrr)
           
gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1.plot6.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

forestplot mrd_coef mrd_lower mrd_upper, ///
           /// graph attributes
           rcols(mrd) leftjustify nostats nobox ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
           /// x-axis
           range(-10 40) null(0) xlabel(-10 0 10 20 30 40, labsize(2.5) nogrid) ///
           xtitle("Mortality rate difference", size(2.5) margin(l=0 r=30 b=0 t=1)) ///         
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           usedims(A) ///
           /// name
           name(fig_mrd)
           
gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

graph combine fig_mrr fig_mrd, graphregion(color(white) lcolor(white) margin(zero)) ysize(4) xsize(5.5)

* Export figure
graph export "${paper_figures}/Appendix10_forest_${date}.png", as(png) replace
clear all


****************************************************************************************************
****************************************************************************************************
* Appendix 11 data - sensitivity analysis not adjusting for BMI
****************************************************************************************************
****************************************************************************************************
* Load data
import excel "${paper_tables}/Appendix11_data.xlsx", sheet("Sheet1") firstrow clear

* Indicator variable needed for forestplot to work
gen _USE = 1
replace _USE = 0 if mi(mrr_coef)

* Label variables
label variable label "{bf:Country}"
label variable mrr `"`"{bf:Mortality rate}"' `"{bf:ratio}"'"'
label variable mrd `"`"{bf:Mortality rate}"' `"{bf:difference}"'"'

* Log of variables
destring mrr_coef mrr_lower mrr_upper mrd_coef mrd_lower mrd_upper, replace
replace mrr_coef = log(mrr_coef)
replace mrr_lower = log(mrr_lower)
replace mrr_upper = log(mrr_upper)

* Plot
forestplot mrr_coef mrr_lower mrr_upper, eform ///
           /// graph attributes
           labels(label) rcols(mrr) leftjustify nostats nobox astext(70) ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
           /// x-axis
           range(0.5 3) null(1) xlabel(0.5 "0.5" 1 2 3, labsize(2.5) nogrid) ///
           xtitle("Mortality rate ratio", size(2.5) margin(l=7 r=0 b=0 t=1)) ///
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           aspect(0.5) savedims(A) ///
           /// name
           name(fig_mrr)

gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1.plot6.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

forestplot mrd_coef mrd_lower mrd_upper, ///
           /// graph attributes
           rcols(mrd) leftjustify nostats nobox ///
           /// markers           
           nlineopts(lwidth(0.2rs)) olineopts(lcolor(black)) pointopts(msymbol(square) msize(0.25rs)) ///
           /// x-axis
           range(-10 35) null(0) xlabel(-10 0 10 20 30, labsize(2.5) nogrid) ///
           xtitle("Mortality rate difference", size(2.5) margin(l=0 r=30 b=0 t=1)) ///         
           /// plot/graph region
           plotregion(margin(l=0 r=0 b=0 t=0) lcolor(none)) ///
           graphregion(color(white) lcolor(white) margin(l=0 r=0 b=0 t=0)) ///           
           /// size
           usedims(A) ///
           /// name
           name(fig_mrd)

gr_edit .plotregion1.plot5.style.editstyle label(textstyle(size(3))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(solid) color(black)) editcopy
gr_edit .yaxis1.draw_view.setstyle, style(off)

graph combine fig_mrr fig_mrd, graphregion(color(white) lcolor(white) margin(zero)) ysize(4) xsize(5.5)

* Export figure
graph export "${paper_figures}/Appendix11_forest_bmi_${date}.png", as(png) replace
clear all


****************************************************************************************************
* Close Log
****************************************************************************************************
log close

